home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / ASM32PM.ZIP / EXAMPLE.ASM next >
Assembly Source File  |  1993-06-07  |  7KB  |  235 lines

  1.         .386p
  2.         jumps
  3.  
  4. code16  segment para public use16
  5.         assume cs:code16, ds:code16
  6.  
  7. ;─────────────────────────────────────────────────────────────────────────────
  8. rmirq0:                                 ; real mode IRQ0 handler
  9.         push ax ds
  10.         mov ax,0b800h
  11.         mov ds,ax
  12.         xor word ptr ds:[(4*160)+(38h*2)],0fdbh
  13.         pop ds
  14.         mov al,20h
  15.         out 20h,al
  16.         pop ax
  17.         iret
  18.  
  19. code16  ends
  20.  
  21. code32  segment para public use32
  22.         assume cs:code32, ds:code32
  23.  
  24. include pmode.inc
  25.  
  26. public  _main
  27.  
  28. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  29. ; DATA
  30. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  31. ormirq0         dd      ?               ; old real mode IRQ handler seg:off
  32. opmirq0         dd      ?               ; old protected mode IRQ handler off
  33.  
  34. hextbl          db      '0123456789ABCDEF'
  35.  
  36. mainstr0        db      'System type:',0
  37. mainstr1        db      'Low memory free:',0
  38. mainstr2        db      'Extended memory free:',0
  39.  
  40. systypestrtbl   dd      sysstr0,sysstr1,sysstr2,sysstr3
  41. sysstr0         db      'raw',0
  42. sysstr1         db      'XMS',0
  43. sysstr2         db      'VCPI',0
  44. sysstr3         db      'DPMI',0
  45.  
  46. keystr          db      'Press any key to go on...',0
  47.  
  48. box1str0        db      'Box 1:',0
  49. box1str1        db      '(protected mode IRQ)',0
  50. box2str0        db      'Box 2:',0
  51. box2str1        db      '(real mode IRQ)',0
  52.  
  53. infostr0a       db      'Both box 1 and 2 should now be flashing. If only box 1 is flashing, and the',0
  54. infostr0b       db      'system type is DPMI, then your DPMI host is not fully compliant.',0
  55. infostr1a       db      'Only box 2 should now be flashing. Unless the system type is DPMI. In this',0
  56. infostr1b       db      'case, both boxes should be flashing.',0
  57.  
  58. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  59. ; CODE
  60. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  61.  
  62. ;─────────────────────────────────────────────────────────────────────────────
  63. pmirq0:                                 ; protected mode IRQ0 handler
  64.         push ds
  65.         mov ds,cs:_selzero
  66.         xor word ptr ds:[0b8000h+(2*160)+(38h*2)],0fdbh
  67.         pop ds
  68.         jmp cs:opmirq0                  ; chain to old IRQ0 redirector
  69.  
  70. ;═════════════════════════════════════════════════════════════════════════════
  71. _main:
  72.         sti
  73.  
  74.         mov eax,gs:[8*4]                ; save real mode IRQ0 vector
  75.         mov ormirq0,eax
  76.         xor bl,bl                       ; get protected mode IRQ0 redirector
  77.         call _getirqvect
  78.         mov opmirq0,edx
  79.  
  80.         @rlp edi,0b8000h                ; fill VGA screen with char 176
  81.         mov ecx,80*25
  82.         mov ax,08b0h
  83.         rep stosw
  84.  
  85.         mov ah,7                        ; put system type
  86.         mov bx,202h
  87.         mov edx,offset mainstr0
  88.         call _putstr
  89.         mov ah,0fh
  90.         mov bl,24
  91.         movzx ecx,_sysbyte0
  92.         and cl,3
  93.         mov edx,systypestrtbl[ecx*4]
  94.         call _putstr
  95.  
  96.         mov ah,7                        ; put amount of low memory
  97.         mov bx,302h
  98.         mov edx,offset mainstr1
  99.         call _putstr
  100.         @rlp edi,0b8000h+(3*160)+(24*2)
  101.         call _lomemsize
  102.         call _puthexnum
  103.  
  104.         mov ah,7                        ; put amount of extended memory
  105.         mov bx,402h
  106.         mov edx,offset mainstr2
  107.         call _putstr
  108.         @rlp edi,0b8000h+(4*160)+(24*2)
  109.         call _himemsize
  110.         call _puthexnum
  111.  
  112.         mov ah,7                        ; put box strings and boxes
  113.         mov bx,231h
  114.         mov edx,offset box1str0
  115.         call _putstr
  116.         mov bl,3ah
  117.         mov edx,offset box1str1
  118.         call _putstr
  119.         mov bx,431h
  120.         mov edx,offset box2str0
  121.         call _putstr
  122.         mov bl,3ah
  123.         mov edx,offset box2str1
  124.         call _putstr
  125.         mov word ptr gs:[0b8000h+(2*160)+(38h*2)],0fdbh
  126.         mov word ptr gs:[0b8000h+(4*160)+(38h*2)],0fdbh
  127.  
  128.         mov ah,8ch                      ; put key message
  129.         mov bx,171bh
  130.         mov edx,offset keystr
  131.         call _putstr
  132.  
  133.         call _waitforkey                ; non-INT16 wait for keypress
  134.  
  135.         cli                             ; set IRQ0 to flash boxes
  136.         xor bl,bl
  137.         mov edx,offset pmirq0
  138.         call _setirqvect
  139.         mov word ptr gs:[8*4],offset rmirq0
  140.         mov word ptr gs:[(8*4)+2],code16
  141.         sti
  142.  
  143.         mov ah,7                        ; put first info
  144.         mov bx,702h
  145.         mov edx,offset infostr0a
  146.         call _putstr
  147.         mov bh,8
  148.         mov edx,offset infostr0b
  149.         call _putstr
  150.  
  151.         call _waitforkey                ; non-INT16 wait for keypress again
  152.  
  153.         mov ah,7                        ; put first info
  154.         mov bx,0a02h
  155.         mov edx,offset infostr1a
  156.         call _putstr
  157.         mov bh,0bh
  158.         mov edx,offset infostr1b
  159.         call _putstr
  160.  
  161.         mov v86r_ah,0                   ; real mode BIOS key wait
  162.         mov al,16h
  163.         int 33h
  164.  
  165.         mov eax,ormirq0                 ; restore old real mode IRQ0 vector
  166.         mov gs:[8*4],eax
  167.  
  168.         jmp _exit
  169.  
  170. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  171. ; Just wait for a keypress (and nullify it)
  172. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  173. _waitforkey:
  174.         push ax
  175. waitforkeyl0:
  176.         mov ax,gs:[41ah]
  177.         cmp ax,gs:[41ch]
  178.         je waitforkeyl0
  179.         mov gs:[41ch],ax
  180.         pop ax
  181.         ret
  182.  
  183. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  184. ; Put ASCIIZ string to screen
  185. ; In:
  186. ;   AH - attribute
  187. ;   BL - X
  188. ;   BH - Y
  189. ;   EDX -> ASCIIZ string
  190. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  191. _putstr:
  192.         push ax esi edi
  193.         movzx edi,bh
  194.         imul edi,160
  195.         movzx esi,bl
  196.         shl esi,1
  197.         lea edi,[edi+esi+0b8000h]
  198.         sub edi,_code32a
  199.         mov esi,edx
  200. putstrl0:
  201.         lodsb
  202.         or al,al
  203.         jz short putstrd
  204.         stosw
  205.         jmp putstrl0
  206. putstrd:
  207.         pop edi esi ax
  208.         ret
  209.  
  210. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  211. ; Put 8 digit hex number to screen buffer
  212. ; In:
  213. ;   EAX - number to put
  214. ;   EDI -> screen buffer location to put at
  215. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  216. _puthexnum:
  217.         push eax ebx ecx edx edi
  218.         mov ebx,offset hextbl
  219.         mov edx,eax
  220.         mov ecx,8
  221.         mov ah,0fh
  222. puthexnuml0:
  223.         rol edx,4
  224.         mov al,dl
  225.         and al,0fh
  226.         xlat
  227.         stosw
  228.         loop puthexnuml0
  229.         pop edi edx ecx ebx eax
  230.         ret
  231.  
  232. code32  ends
  233.         end
  234.  
  235.